package com.wrx.club_management_backend.controller;

import com.wrx.club_management_backend.common.AjaxResult;
import com.wrx.club_management_backend.entity.News;
import com.wrx.club_management_backend.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/news")
public class NewsController {

    @Autowired
    NewsService newsService;

    /**
     * 根据用户id 获取动态列表
     * 收藏的社团社长 === 朋友
     * @return 动态列表
     */
    @GetMapping("/getByCurUser")
    public AjaxResult getByCurUser(){
        return newsService.getByCurUser();
    }

    /**
     * 发布动态
     * @param news 动态
     * @return res
     */
    @PostMapping("/push")
    public AjaxResult push(@RequestBody News news){
        return newsService.push(news);
    }

    /**
     * 查询动态数量
     * @return 动态数量
     */
    @GetMapping("/num")
    public AjaxResult num(){
        return newsService.num();
    }

    @GetMapping("/like/{newsId}")
    public AjaxResult like(@PathVariable("newsId") Long newsId ){
        return newsService.like(newsId);
    }

}
